/*
 * @Author: 谢陈洁
 * @Date: 2025-07-14 11:25:44
 * @LastEditors: 谢陈洁
 * @LastEditTime: 2025-07-14 16:26:44
 * @Description: useOptions hooks 封装 生成下拉框数据
 * @Params: options 下拉框数据 propName 下拉框数据的key propName 默认为categoryId
 * @Return: { generateOptions } generateOptions 生成下拉框数据
 */
export function useOptions(propName = 'categoryId') {
  const generateOptions = (config: any[], options: any[]) => {
    console.log('options', options, config);
    return config.map(item => {
      if (item.prop === propName) {
        return {
          ...item,
          children: options.map((cat: any) => ({
            label: cat.name,
            value: cat.id
          }))
        }
      }
      return item
    })
  }

  return {
    generateOptions
  }
}
